package design.pattern.状态模式;

/**
 * 具体状态类：自由时间，无拘无束
 */
public class FreeState implements State{
    @Override
    public void handle(Context context) {
        if(context.getHour() < 18 && context.getHour() > 9){
            context.setState(new AfternoonState()).request();
        } else if(context.getHour() >= 9 && context.getHour() < 18){
            context.setState(new ForenoonState()).request();
        } else {
            System.out.println("现在时间:" + context.getHour() + ", 下班了，自由时间无拘无束。");
        }
    }
}
